// import * as VerApi from '/@/api/business/flowable/ver'
import { ref } from "vue";
import { message } from "ant-design-vue";

export function useVerApi(loading) {
  const workflowVer = ref()
  const workflowVerList = ref([])

  async function findVer(param) {
    try {
      loading && (loading.value = true)
      let temp = await VerApi.findVer(param)
      workflowVer.value = temp.data
    } catch (e) {
      console.error(e)
      message.error(e?.message || '查询失败')
    } finally {
      loading && (loading.value = false)
    }
  }

  async function findVerList(param) {
    try {
      loading && (loading.value = true)
      let temp = await VerApi.findVerList(param)
      workflowVerList.value = temp.data
    } catch (e) {
      console.error(e)
      message.error(e?.message || '查询失败')
    } finally {
      loading && (loading.value = false)
    }
  }

  async function updateXml(param) {
    try {
      loading && (loading.value = true)
      await VerApi.updateXml(param)
      message.success('更新成功')
    } catch (e) {
      console.error(e)
      message.error(e?.message || '更新失败')
    } finally {
      loading && (loading.value = false)
    }
  }

  return {
    workflowVer, findVer,
    workflowVerList, findVerList,
    updateXml,
  }
} 